﻿using System.Configuration;
using System.Web.Configuration;

namespace Utilities
{
    public class Conf
    {
        private readonly Configuration _config;

        public Conf(string exePath)
        {
            var roamingConfig = WebConfigurationManager.OpenWebConfiguration(exePath);
            var configFileMap = new ExeConfigurationFileMap
                                    {
                                        ExeConfigFilename = roamingConfig.FilePath
                                    };
            _config = ConfigurationManager.OpenMappedExeConfiguration(configFileMap, ConfigurationUserLevel.None);
        }

        public string Db(string setting)
        {
            return _config.ConnectionStrings.ConnectionStrings[setting].ConnectionString;
        }

        public string App(string setting)
        {
            return _config.AppSettings.Settings[setting].Value;
        }
    }
}
